package com.mystudio.android.calendar.view;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.mystudio.android.calendar.R;

public class DayInMonthView extends RelativeLayout {
	private TextView dayText;
	private TextView chiDayText;
	private LinearLayout eventsList;
	
	public DayInMonthView(Context context, AttributeSet attributes) {
		super(context, attributes);

		LayoutInflater inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		inflater.inflate(R.layout.day_in_month, this, true);
		
		dayText = (TextView)findViewById(R.id.DayText);
		chiDayText = (TextView)findViewById(R.id.ChiDayText);
		eventsList = (LinearLayout)findViewById(R.id.EventsList);
	}
	
	public void setDay(int day) {
		dayText.setText(String.valueOf(day));
	}

	public void setDim() {
		setBackgroundResource(R.color.day_in_month_dim_bg);
		int color = getResources().getColor(R.color.day_in_month_dim_text);
		dayText.setTextColor(color);
		chiDayText.setTextColor(color);
	}

	public void setChiDay(String chiDay) {
		chiDayText.setText(chiDay);
	}
	
	public void clearEvents() {
		eventsList.removeAllViews();
	}
	
	public void addEvent(String title, int color) {
		LayoutInflater inflater = (LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		TextView textView = (TextView)inflater.inflate(R.layout.events_in_day, null);
			textView.setText(title);
			textView.setTextColor(color);
			
		eventsList.addView(textView);
	}
}
